home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / wheels2.arc / POPSCREN.PAS < prev    next >
Pascal/Delphi Source File  |  1985-06-28  |  6KB  |  169 lines

  1. {@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
  2. The purchaser of these procedures and functions may include them in COMPILED
  3. programs freely, but may not sell or give away the source text.
  4.  
  5.     A variable type is declared in SCREENS.TYP that is the same "shape"
  6.     as the (text) screen memory.  Using the "absolute" clause we
  7.     can define variables "MONO" and "COLO" that exist "on top of" the
  8.     Monochrome and Color screen memories.  If we then switch in some
  9.     other SCREEN variable (e.g., "Mono := new_screen"), the whole
  10.     video display changes instantly.
  11.  
  12.     The procedure MAKESCREEN takes a line of text and converts it into
  13.     one line of a screen variable.  You can get a screen into memory by
  14.     reading it from a file (see GetScreensFromFile below), by using
  15.     MAKESCREEN on text constants (see CreateAScreen below), or by
  16.     "grabbing" it from the screen memory itself (see GrabScreen below).
  17.  
  18.     One possible application for this sort of screen manipulation is
  19.     a POP-out menu.  Your program can "grab" the current screen, write
  20.     the menu onto the display, and then restore the screen.
  21. }
  22.  
  23. {$I screens.typ}
  24. {$I popscren.lib}
  25. {$I monitor.lib}
  26. {$I getkeys.lib}
  27. {$I grfxtabl.lib}
  28. {$I titles.lib}
  29.  
  30. var
  31.   Pops    : array[1..5] of screen;
  32.   N, M    : byte;
  33.   PopFile : text;
  34.   OneLine : lineType;
  35.   C, D    : char;
  36.   Your_title : title_type;
  37.  
  38. {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
  39. procedure GetScreensFromFile;
  40. {This is one way to put screens into memory}
  41.  
  42. begin
  43.   Assign(PopFile,'POPSCREN.DAT');
  44.   reset(PopFile);
  45.   N := 0;
  46.   while (not EOF(PopFile)) and (N < 25) do
  47.     begin
  48.       N := N + 1;
  49.       readLn(PopFile,OneLine);
  50.       MakeScreen(Pops[1][N],15,OneLine);
  51.       MakeScreen(Pops[2][N],112,OneLine);
  52.       MakeScreen(Pops[3][N],1,OneLine);
  53.     end;
  54.   close(PopFile);
  55. end;
  56. {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
  57. procedure CreateAScreen;
  58.    {This is another way to create a screen}
  59.  
  60. begin
  61. MakeScreen(Pops[4][1],15,'');
  62. MakeScreen(Pops[4][2],15,'');
  63. MakeScreen(Pops[4][3],15,'');
  64. MakeScreen(Pops[4][4],15,'');
  65. MakeScreen(Pops[4][5],15,
  66. 'THIS SCREEN WAS NOT READ FROM THAT FILE.');
  67. MakeScreen(Pops[4][6],15,
  68. '  THIS SCREEN WAS NOT READ FROM THAT FILE.');
  69. MakeScreen(Pops[4][7],15,
  70. '     THIS SCREEN WAS NOT READ FROM THAT FILE.');
  71. MakeScreen(Pops[4][8],15,
  72. '        THIS SCREEN WAS NOT READ FROM THAT FILE.');
  73. MakeScreen(Pops[4][9],15,
  74. '           THIS SCREEN WAS NOT READ FROM THAT FILE.');
  75. MakeScreen(Pops[4][10],15,
  76. '              THIS SCREEN WAS NOT READ FROM THAT FILE.');
  77. MakeScreen(Pops[4][11],15,
  78. '                 THIS SCREEN WAS NOT READ FROM THAT FILE.');
  79. MakeScreen(Pops[4][12],15,
  80. '                    THIS SCREEN WAS NOT READ FROM THAT FILE.');
  81. MakeScreen(Pops[4][13],15,
  82. '                       THIS SCREEN WAS NOT READ FROM THAT FILE.');
  83. MakeScreen(Pops[4][14],15,
  84. '                          THIS SCREEN WAS NOT READ FROM THAT FILE.');
  85. MakeScreen(Pops[4][15],15,
  86. '                             THIS SCREEN WAS NOT READ FROM THAT FILE.');
  87. MakeScreen(Pops[4][16],15,
  88. '                                THIS SCREEN WAS NOT READ FROM THAT FILE.');
  89. MakeScreen(Pops[4][17],15,
  90. '                                   THIS SCREEN WAS NOT READ FROM THAT FILE.');
  91. MakeScreen(Pops[4][18],15,
  92. '                                      THIS SCREEN WAS NOT READ FROM THAT FILE.');
  93. for N := 19 to 25 do
  94. MakeScreen(Pops[4][N],15,'');
  95. end;
  96. {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
  97. procedure GrabScreen;    {Here we "grab" a screen from the actual display}
  98. begin
  99.   WRite('Enter a word of 10 letters or less: ');
  100.   ReadLn(your_title);
  101.   ClrScr;
  102.   MakeTitle(your_title,1);
  103.   MakeTitle(your_title,9);
  104.   MakeTitle(your_title,17);
  105.   if color then Pops[5] := Colo
  106.     else Pops[5] := Mono;
  107.   ClrScr;
  108. end;
  109. {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
  110. procedure MenuDemo;
  111. begin
  112.   for N := 1 to 5 do
  113.     begin
  114.       WriteLn('Now to fill the screen with text, in preparation for a');
  115.       WriteLn('demonstration of a pop-out menu.  Pressing a key saves');
  116.       WriteLn('the current screen & shows the menu.');
  117.       WriteLn;
  118.     end;
  119.  
  120.   repeat
  121.     GetKeys(C,D);
  122.     if ((C = #27) and (D = ';')) then
  123.       begin
  124.         Mono := Pops[5];
  125.         Colo := Pops[5];
  126.       end
  127.     else
  128.       begin
  129.         if color then Pops[5] := Colo
  130.           else Pops[5] := Mono;
  131.         TextColor(black);TextBackground(white);
  132.         GotoXY(20,5);Write ('╔══════════════════════════════╗');
  133.         GotoXY(20,6);Write ('║                              ║');
  134.         GotoXY(20,7);Write ('║  This might well be a menu.  ║');
  135.         GotoXY(20,8);Write ('║  Press F1 to restore the     ║');
  136.         GotoXY(20,9);Write ('║  screen, F2 to end           ║');
  137.         GotoXY(20,10);Write('║                              ║');
  138.         GotoXY(20,11);Write('╚══════════════════════════════╝');
  139.         TextColor(white);TextBackground(black);
  140.      end;
  141.    until (C = #27) and (D = '<');
  142. end;
  143. {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
  144. begin
  145.   WriteLn('This is a demonstration of directly writing WHOLE SCREENS to the');
  146.   WriteLn('display.  First, a "picture" screen is read from disk in three');
  147.   WriteLn('different colors.  Next a screen is created directly within this');
  148.   WriteLn('program.  Finally, a screen is created on the display and "grabbed"');
  149.   WriteLn('by the program.');
  150.   WriteLn('After all that, you get a demo of a SCREEN menu.');
  151.   WriteLn('Press a key to start it all');
  152.   repeat until keypressed;
  153.   CheckColor;
  154.   GetScreensFromFile;
  155.   CreateAScreen;
  156.   GrabScreen;
  157.   GotoXY(2,2); write('Keep pressing a key for a quick change of screen.');
  158.   Write('<Esc> to go on.');
  159.   N := 0;
  160.   repeat
  161.     GetKeys(C,D);
  162.     N := N + 1;
  163.     Mono := Pops[(N mod 5) + 1];
  164.     Colo := Pops[(N mod 5) + 1];
  165.   until (C = #27) and (D = #0);
  166.   ClrScr;
  167.   MenuDemo;
  168.   ClrScr;
  169. end.